//
//  PersonInfoViewController.m
//  囧途
//
//  Created by fly on 16/3/7.
//  Copyright © 2016年 fly. All rights reserved.
//

#import "PersonInfoViewController.h"
#import <AVObject.h>
#import <AVUser.h>
@interface PersonInfoViewController ()
@property (strong, nonatomic) IBOutlet UIButton *changeHeadImage;

@property (strong, nonatomic) IBOutlet UITextField *nameLabel;

@property (strong, nonatomic) IBOutlet UITextField *phoneNumebr;

@property (strong, nonatomic) IBOutlet UITextField *address;


@property (strong, nonatomic) IBOutlet UIButton *addButton;
@end

@implementation PersonInfoViewController

- (void)viewDidLoad {
    [super viewDidLoad];
   }

- (IBAction)changeHeadImagePressed:(UIButton *)sender {
    
    
}

- (IBAction)addButtonPressed:(UIButton *)sender {
    AVUser * user = [AVUser currentUser];
    
    AVObject * obj = [AVObject objectWithoutDataWithClassName:@"_User" objectId:user.objectId];
    
    [obj setObject:_nameLabel.text forKey:@"NameLabel"];
    
    [obj setObject:_phoneNumebr.text forKey:@"TurePhoneNumber"];
    
    [obj setObject:_address.text forKey:@"Address"];
    
    [obj saveInBackgroundWithBlock:^(BOOL succeeded, NSError *error) {
        UIAlertController * alert = [UIAlertController alertControllerWithTitle:@"提示" message:@"修改成功！" preferredStyle:UIAlertControllerStyleAlert];
        
        UIAlertAction * alertAction = [UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
            
            [self.navigationController popViewControllerAnimated:YES];
           
        }];
        
        [alert addAction:alertAction];
        
        [self presentViewController:alert animated:YES completion:nil];
 
    }];
    
    
    
}

-(void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event
{
    [self.view endEditing:YES];
}

@end
